'''
读excel
'''

'''
读取Excel分四步：
1. 打开excel
2. 获取excel的sheet
3. 获取excel的行、列
4. 读取内容

 请假类型：公休 产假 病假 事假 探亲假 工伤假 婚假 

'''
# -*- coding: utf-8 -*-
import xlrd
import xlwt
from datetime import date, datetime


def read_excel(file_path):
    # 打开文件
    workbook = xlrd.open_workbook(file_path)
    # 获取所有sheet
    # print(workbook.sheet_names())
    sheet = workbook.sheet_by_index(0)
    rows = sheet.nrows  # 行
    cols = sheet.ncols  # 列


    gongxiu_dicts = {}
    bingjia_dicts = {}
    chanjia_dicts = {}
    shijia_dicts ={}
    for i in range(0, rows):
        n = 0
        n2 = 0
        name = ''
        temp = {}

        for t in range(0, cols):
            if sheet.row(i)[t].value == '公休':
                # print(sheet.row(i)[3].value)
                name = sheet.row(i)[3].value
                n += 1
                gongxiu_dicts[name] = n

            if sheet.row(i)[t].value == '产假':

                name = sheet.row(i)[3].value
                n2 += 1
                chanjia_dicts[name] = n2

    for key, value in gongxiu_dicts.items():
        print(key+' 公休:'+str(value)+'天')
    print('-----------')
    
    for key, value in chanjia_dicts.items():
        print(key+' 产假:'+str(value)+'天')


if __name__ == '__main__':
    read_excel()

